//
//  XRCommonOnlyTextFieldTableCell.m
//  XClassRoom
//
//  Created by mac on 16/11/7.
//  Copyright © 2016年 Mr-yuwei. All rights reserved.
//

#import "XRCommonOnlyTextFieldTableCell.h"
#define XRCommonOnlyTextFieldTableCellTextHeight  31
@implementation XRCommonOnlyTextFieldTableCell

-(void)addOwnView
{

    [self setBackgroundColor:[UIColor colorWithNSString:@"f2f2f2"]];
    _textField=[[UITextField alloc] init];
    [_textField setBackgroundColor:[ UIColor whiteColor]];
    _textField.layer.borderColor=[UIColor whiteColor].CGColor;
    _textField.layer.borderWidth=0.5;
    _textField.layer.masksToBounds=YES;
    _textField.layer.cornerRadius=4;
    _textField.leftSpace=5.0f;
    _textField.placeholder=@"请输入手机号码";
    [self.contentView addSubview:_textField];
}
-(void)setTextFieldleftMagin:(CGFloat)textFieldleftMagin
{
    _textFieldleftMagin=textFieldleftMagin;
    
    if (_textField)
    {
        [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake((self.bounds.size.height-XRCommonOnlyTextFieldTableCellTextHeight)*0.5, _textFieldleftMagin, (self.bounds.size.height-XRCommonOnlyTextFieldTableCellTextHeight)*0.5, _textFieldleftMagin));
        }];
        
        [self setNeedsLayout];
    }
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
}
@end


@implementation XRCommonOnlyTextFieldWithRightButtonTableCell

-(void)addOwnView
{
    
    [self setBackgroundColor:[UIColor colorWithNSString:@"f2f2f2"]];
    _textField=[[UITextField alloc] init];
    _textField.leftSpace=5.0f;
    _textField.layer.borderColor=[UIColor whiteColor].CGColor;
    _textField.layer.borderWidth=0.5;
    _textField.layer.masksToBounds=YES;
    _textField.layer.cornerRadius=4;
    _textField.placeholder=@" 请输入手机号码";
    _sendButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [_sendButton setBackgroundColor:[UIColor whiteColor]];
    _sendButton .layer.masksToBounds=YES;
    _sendButton .layer.cornerRadius=4.0f;
    _sendButton.titleLabel.font=[UIFont systemFontOfSize:14];
    [_sendButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    
    [self.contentView addSubview:_textField];
    [self.contentView addSubview:_sendButton];
    self.textFieldleftMagin=10;//初始化一下间距
    
}
-(void)setTextFieldleftMagin:(CGFloat)textFieldleftMagin
{
    _textFieldleftMagin=textFieldleftMagin;
    
    if (_textField)
    {
        
        [_sendButton mas_makeConstraints:^(MASConstraintMaker *make)
         {
             make.centerY.equalTo(self.contentView);
             make.right.equalTo(self.contentView).with.offset(-10);
             make.width.mas_equalTo(80);
        }];
        
        [_textField mas_makeConstraints:^(MASConstraintMaker *make)
         {
            make.centerY.equalTo(self.contentView);
            make.height.mas_equalTo(XRCommonOnlyTextFieldTableCellTextHeight+3);
            make.left.equalTo(self.contentView).with.offset(_textFieldleftMagin);
            make.right.equalTo(_sendButton.mas_left).offset(5.0);
        }];
        [self setNeedsLayout];
    }
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
}
@end

